package com.bawei.wyg.mycommerce.homework.two;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;
import android.widget.Toast;

import com.bawei.wyg.mycommerce.R;
import com.bawei.wyg.mycommerce.databinding.ActivityHomeWorkDataBinding;
import com.bawei.wyg.mycommerce.databinding.single.SingleEntity;
import com.bawei.wyg.mycommerce.homework.one.HomeWorkActivity;

public class HomeWorkDataActivity extends AppCompatActivity {
    ActivityHomeWorkDataBinding binding;
    int num=0;
    NumEntity numEntity;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding= DataBindingUtil.setContentView(this,R.layout.activity_home_work_data);
        binding.setSingleClick(new SingleClick());
        numEntity=new NumEntity();
        binding.setEntity(numEntity);
        numEntity.setStrnum(num+"");
    }
    public class SingleClick{
        public void btnClickjia(){
            num++;
            numEntity.setStrnum(num+"");
            Toast.makeText(HomeWorkDataActivity.this, "点击了加", Toast.LENGTH_SHORT).show();
        }
        public void btnClickjian(){
            if(num==0){
                Toast.makeText(HomeWorkDataActivity.this, "已经到0了yoooo~~", Toast.LENGTH_SHORT).show();
            }else{
                num--;
                numEntity.setStrnum(num+"");
            }

            Toast.makeText(HomeWorkDataActivity.this, "点击了减", Toast.LENGTH_SHORT).show();
        }
    }
}